<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2005 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
		
if (stristr(htmlentities($_SERVER['PHP_SELF']), "javascript.php")) {
    Header("Location: ../index.php");
    die();
}

##################################################
# Include for some common javascripts functions  #
##################################################

global $name, $admin, $advanced_editor, $lang, $no_editor, $nukeurl;

if (file_exists("themes/".$ThemeSel."/style/editor.css")) {
    $edtcss = "editor_css : \"themes/".$ThemeSel."/style/editor.css\",";
} else {
    $edtcss = "editor_css : \"includes/tiny_mce/themes/default/editor_ui.css\",";
}

if (is_admin($admin) AND defined('ADMIN_FILE') AND $advanced_editor == 2 AND !defined('NO_EDITOR')) {
	echo "<!-- tinyMCE -->
		<script language=\"javascript\" type=\"text/javascript\" src=\"includes/tiny_mce/tiny_mce.js\"></script>
		<script language=\"javascript\" type=\"text/javascript\">
	   	tinyMCE.init({
		mode : \"textareas\",
		theme : \"advanced\",
		language : \"$lang\",
		force_p_newlines: \"false\",
		force_br_newlines: \"true\",
		plugins : \"table,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print\",
		theme_advanced_buttons1_add : \"fontselect,fontsizeselect\",
		theme_advanced_buttons2_add : \"separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor\",
		theme_advanced_buttons2_add_before: \"cut,copy,paste,separator,search,replace,separator\",
		theme_advanced_buttons3_add_before : \"tablecontrols,separator\",
		theme_advanced_buttons3_add : \"emotions,iespell,flash,advhr,separator,print\",
		theme_advanced_toolbar_location : \"top\",
		theme_advanced_toolbar_align : \"left\",
		theme_advanced_path_location : \"bottom\",
		$edtcss
	    	plugin_insertdate_dateFormat : \"%Y-%m-%d\",
	    	plugin_insertdate_timeFormat : \"%H:%M:%S\",
		extended_valid_elements : \"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]\",
		external_link_list_url : \"example_link_list.js\",
		external_image_list_url : \"example_image_list.js\",
		flash_external_list_url : \"example_flash_list.js\",
		file_browser_callback : \"fileBrowserCallBack\"
	});
	function fileBrowserCallBack(field_name, url, type) {
		// This is where you insert your custom filebrowser logic
		alert(\"Filebrowser callback: \" + field_name + \",\" + url + \",\" + type);
	}		</script>
		<!-- /tinyMCE -->";
} elseif (is_admin($admin) AND $advanced_editor != 2 AND $name != "Private_Messages" AND $name != "Forums" AND !defined('NO_EDITOR')) {
	echo "<!-- tinyMCE -->
		<script language=\"javascript\" type=\"text/javascript\" src=\"includes/tiny_mce/tiny_mce.js\"></script>
		<script language=\"javascript\" type=\"text/javascript\">
	   	tinyMCE.init({
      		mode : \"textareas\",
			theme : \"basic\",
			language : \"$lang\",
			$edtcss
			force_p_newlines: \"false\",
			force_br_newlines: \"true\"
	   	});
		</script>
		<!-- /tinyMCE -->";
} elseif ($name != "Private_Messages" AND $name != "Forums" AND !defined('NO_EDITOR')) {
	echo "<!-- tinyMCE -->
		<script language=\"javascript\" type=\"text/javascript\" src=\"includes/tiny_mce/tiny_mce.js\"></script>
		<script language=\"javascript\" type=\"text/javascript\">
	   	tinyMCE.init({
      		mode : \"textareas\",
			theme : \"default\",
			language : \"$lang\",
			$edtcss
			force_p_newlines: \"false\",
			force_br_newlines: \"true\"
	   	});
		</script>
		<!-- /tinyMCE -->";
}

if (is_admin($admin)) {
	?>
	<script language="javascript"> 
	<!-- 
	var state = 'none'; 
	
	function showhide(layer_ref) { 
	
	if (state == 'block') { 
	state = 'none'; 
	} 
	else { 
	state = 'block'; 
	} 
	if (document.all) { //IS IE 4 or 5 (or 6 beta) 
	eval( "document.all." + layer_ref + ".style.display = state"); 
	} 
	if (document.layers) { //IS NETSCAPE 4 or below 
	document.layers[layer_ref].display = state; 
	} 
	if (document.getElementById &&!document.all) { 
	hza = document.getElementById(layer_ref); 
	hza.style.display = state; 
	} 
	} 
	//--> 
	</script> 
	<?php
}

if ($userpage == 1) {
    echo "<SCRIPT type=\"text/javascript\">\n";
    echo "<!--\n";
    echo "function showimage() {\n";
    echo "if (!document.images)\n";
    echo "return\n";
    echo "document.images.avatar.src=\n";
    echo "'$nukeurl/modules/Forums/images/avatars/gallery/' + document.Register.user_avatar.options[document.Register.user_avatar.selectedIndex].value\n";
    echo "}\n";
    echo "//-->\n";
    echo "</SCRIPT>\n\n";
}

if (defined('MODULE_FILE') AND file_exists("modules/".$name."/copyright.php")) {
    echo "<script type=\"text/javascript\">\n";
    echo "<!--\n";
    echo "function openwindow(){\n";
    echo "	window.open (\"modules/".$name."/copyright.php\",\"Copyright\",\"toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=400,height=200\");\n";
    echo "}\n";
    echo "//-->\n";
    echo "</SCRIPT>\n\n";
}

if($name == "Your Account" || $name == "Your_Account" || $name == "Profile" || defined('ADMIN_FILE')) {
     echo "<script type=\"text/javascript\">";
     echo "function strengthhelp() {";
     echo "    window.open ('includes/passhelp.php','PasswordStrenghtMeter','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=400,height=200');";
     echo "}";
     echo "</script>";

     echo '<script type="text/javascript">
     function chkpwd(w) {
     var StrengthValue
     StrengthValue = 0;

     pwd_upper_case = /[A-Z]/;          // a uppercase letter present
     pwd_lower_case = /[a-z]/;          // a lowercase letter present
     pwd_digit = /d/;             // a digit present
     pwd_other = /W/;             // a non letter or digit present
     pwd_length = /^[a-zdW]{10,}$/i;

     if (pwd_upper_case.test(w) == true) {StrengthValue = StrengthValue + 1;};
     if (pwd_lower_case.test(w) == true) {StrengthValue = StrengthValue + 1;};
     if (pwd_digit.test(w) == true) {StrengthValue = StrengthValue + 1;};
     if (pwd_other.test(w) == true) {StrengthValue = StrengthValue + 1;};
     if (pwd_length.test(w) == true) {StrengthValue = StrengthValue + 1;};

     document.getElementById("divTEMP").innerHTML = "Derece: " + StrengthValue + "/5";

     if (StrengthValue == 0) {
      document.getElementById("div1").innerHTML = "";
      document.getElementById("div2").innerHTML = "";
      document.getElementById("div3").innerHTML = "<em>Kontrol</em>";
      document.getElementById("div4").innerHTML = "";
      document.getElementById("div5").innerHTML = "";
      document.getElementById("td1").style.backgroundColor = "#EBEBEB";
      document.getElementById("td2").style.backgroundColor = "#EBEBEB";
      document.getElementById("td3").style.backgroundColor = "#EBEBEB";
      document.getElementById("td4").style.backgroundColor = "#EBEBEB";
      document.getElementById("td5").style.backgroundColor = "#EBEBEB";
     };

     if (StrengthValue == 1) {
      document.getElementById("div1").innerHTML = "<em>Güvensiz</em>";
      document.getElementById("div2").innerHTML = "";
      document.getElementById("div3").innerHTML = "";
      document.getElementById("div4").innerHTML = "";
      document.getElementById("div5").innerHTML = "";
      document.getElementById("td1").style.backgroundColor = "#FF4545";
      document.getElementById("td2").style.backgroundColor = "#EBEBEB";
      document.getElementById("td3").style.backgroundColor = "#EBEBEB";
      document.getElementById("td4").style.backgroundColor = "#EBEBEB";
      document.getElementById("td5").style.backgroundColor = "#EBEBEB";
     };

     if (StrengthValue == 2) {
      document.getElementById("div1").innerHTML = "";
      document.getElementById("div2").innerHTML = "<em>Orta</em>";
      document.getElementById("div3").innerHTML = "";
      document.getElementById("div4").innerHTML = "";
      document.getElementById("div5").innerHTML = "";
      document.getElementById("td1").style.backgroundColor = "#FFFF33";
      document.getElementById("td2").style.backgroundColor = "#FFFF33";
      document.getElementById("td3").style.backgroundColor = "#EBEBEB";
      document.getElementById("td4").style.backgroundColor = "#EBEBEB";
      document.getElementById("td5").style.backgroundColor = "#EBEBEB";
     };

     if (StrengthValue == 3) {
      document.getElementById("div1").innerHTML = "";
      document.getElementById("div2").innerHTML = "";
      document.getElementById("div3").innerHTML = "<em>Normal</em>";
      document.getElementById("div4").innerHTML = "";
      document.getElementById("div5").innerHTML = "";
      document.getElementById("td1").style.backgroundColor = "#FFD35E";
      document.getElementById("td2").style.backgroundColor = "#FFD35E";
      document.getElementById("td3").style.backgroundColor = "#FFD35E";
      document.getElementById("td4").style.backgroundColor = "#EBEBEB";
      document.getElementById("td5").style.backgroundColor = "#EBEBEB";
     };

      if (StrengthValue == 4) {
       document.getElementById("div1").innerHTML = "";
       document.getElementById("div2").innerHTML = "";
       document.getElementById("div3").innerHTML = "";
       document.getElementById("div4").innerHTML = "<em>İyi</em>";
       document.getElementById("div5").innerHTML = "";
       document.getElementById("td1").style.backgroundColor = "#66FF66";
       document.getElementById("td2").style.backgroundColor = "#66FF66";
       document.getElementById("td3").style.backgroundColor = "#66FF66";
       document.getElementById("td4").style.backgroundColor = "#66FF66";
       document.getElementById("td5").style.backgroundColor = "#EBEBEB";
     };

      if (StrengthValue == 5) {
       document.getElementById("div1").innerHTML = "";
       document.getElementById("div2").innerHTML = "";
       document.getElementById("div3").innerHTML = "";
       document.getElementById("div4").innerHTML = "";
       document.getElementById("div5").innerHTML = "<em>Mükemmel</em>";
       document.getElementById("div5").innerHTML.textColor =  "#3ABB1C";
       document.getElementById("td1").style.backgroundColor = "#3ABB1C";
       document.getElementById("td2").style.backgroundColor = "#3ABB1C";
       document.getElementById("td3").style.backgroundColor = "#3ABB1C";
       document.getElementById("td4").style.backgroundColor = "#3ABB1C";
       document.getElementById("td5").style.backgroundColor = "#3ABB1C";
     };

     if (w.length < 4) {
      document.getElementById("div1").innerHTML = "";
      document.getElementById("div2").innerHTML = "";
      document.getElementById("div3").innerHTML = "<em>Kontrol</em>";
      document.getElementById("div4").innerHTML = "";
      document.getElementById("div5").innerHTML = "";
      document.getElementById("td1").style.backgroundColor = "#EBEBEB";
      document.getElementById("td2").style.backgroundColor = "#EBEBEB";
      document.getElementById("td3").style.backgroundColor = "#EBEBEB";
      document.getElementById("td4").style.backgroundColor = "#EBEBEB";
      document.getElementById("td5").style.backgroundColor = "#EBEBEB";
     };
    }
    </script>';
    echo "";
}

echo"<script language=\"JavaScript\" type=\"text/javascript\">
function makecookie(Name,Value,Expiry,Path,Domain,Secure){
if (Expiry!= null) {
var datenow = new Date();
datenow.setTime(datenow.getTime() + Math.round(86400000*Expiry));
Expiry = datenow.toGMTString();
}

Expiry = (Expiry!= null)? '; expires='+Expiry : '';
Path = (Path!= null)?'; path='+Path:'';
Domain = (Domain!= null)? '; domain='+Domain : '';
Secure = (Secure!= null)? '; secure' : '';

document.cookie = Name + '=' + escape(Value) + Expiry + Path + Domain + Secure;
}

function readcookie(Name) {
var cookies = document.cookie;
if (cookies.indexOf(Name + '=') == -1) return null;
var start = cookies.indexOf(Name + '=') + (Name.length + 1);
var finish = cookies.substring(start,cookies.length);
finish = (finish.indexOf(';') == -1)? cookies.length : start + finish.indexOf(';');
return unescape(cookies.substring(start,finish));
}

function setActivestyleSheet(pTitle) {
var vLoop, vLink;
for(vLoop=0; (vLink = document.getElementsByTagName(\"link\")[vLoop]); vLoop++) {
if(vLink.getAttribute(\"rel\").indexOf(\"style\")!= -1 && vLink.getAttribute(\"title\")) {
vLink.disabled = true;
if(vLink.getAttribute(\"title\") == pTitle) vLink.disabled = false;
}
}
}

function stilsec (vSelection) {
makecookie('style', vSelection, 90, '/');
setActivestyleSheet(vSelection)
}

if (document.cookie.indexOf('style')!=-1) {
css = readcookie('style');
//ACTIVATE SELECTED style SHEET
setActivestyleSheet(css)
}

</script>";

?>